import logging
import os
import time

#logger object
logger_name = 'Master'
logger = logging.getLogger(logger_name)
logger.setLevel(logging.DEBUG)

#formatter object
fmt = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
formatter = logging.Formatter(fmt)

#stream handler object
console = logging.StreamHandler()
console.setLevel(logging.INFO)
console.setFormatter(formatter)

#file handler object
path = os.getcwd() + '//' + 'log'
file = "Stock_Account_Simulator_{0}_log.txt".format(time.strftime("%Y%m%d%H%M%S", time.localtime()))
filename = path + '//'+ file

file_console = logging.FileHandler(filename)
file_console.setLevel(logging.DEBUG)
file_console.setFormatter(formatter)

#add handler object to logger object
logger.addHandler(console)
logger.addHandler(file_console)

#test beginning
logger.info('Logging function enable.')